home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14174 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: solon.com!not-for-mail
  2. From: seebs@solutions.solon.com (Peter Seebach)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: fastest code
  5. Date: 12 Apr 1996 07:46:28 -0500
  6. Organization: Usenet Fact Police (Undercover)
  7. Message-ID: <4kljb4$nm3@solutions.solon.com>
  8. References: <316112A2.7D37@public.sta.net.cn> <4kghs7$250@news1.mnsinc.com> <4kgu7g$n9a@solutions.solon.com> <yxsbukxemoi.fsf@stint.cl.cam.ac.uk>
  9. Reply-To: seebs@solon.com
  10. NNTP-Posting-Host: solutions.solon.com
  11.  
  12. In article <yxsbukxemoi.fsf@stint.cl.cam.ac.uk>,
  13. Gareth Rees <gdr11@cl.cam.ac.uk> wrote:
  14. >Surely, under the `as if' rule, code that invokes undefined behaviour
  15. >*at any point* need not produce the results you expect even for those
  16. >portions that don't invoke undefined behaviour?
  17.  
  18. True, although in practice it doesn't come up.
  19.  
  20. >So in the case
  21.  
  22. >    int x[17], i;
  23. >    for (i=0; i<16; i++) x[i] = x[i+i];
  24.  
  25. >the compiler is perfectly at liberty to optimise away the loop body
  26. >because of the undefined behaviour of the whole program.
  27.  
  28. Right.  As it turns out, x had dimension 32 in the original post, but this
  29. was not posted along with the loop description.
  30.  
  31. -s
  32. -- 
  33. Peter Seebach - seebs@solon.com - Copyright 1996 Peter Seebach.
  34. C/Unix wizard -- C/Unix questions? Send mail for help.  No, really!
  35. FUCK the communications decency act.  Goddamned government.  [literally.]
  36. The *other* C FAQ - http://www.solon.com/~seebs/c/c-iaq.html
  37.